home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / borland / jnfb88.zip / COMINC.ZIP / COM2INC.BAS next >
BASIC Source File  |  1987-09-22  |  2KB  |  51 lines

  1. '  COM2INC.BAS
  2. '  Written in Turbo Basic by Bruce Tonkin on 5/11/87
  3. '
  4. '  This program converts COM files to $INCLUDE text files
  5. '  with the Turbo Basic $INLINE meta-command.  The output
  6. '  files may be inserted or easily $INCLUDEd into
  7. '  Turbo Basic programs.
  8. '
  9. DEFINT A-Z         'All variables will be integers
  10. F$=COMMAND$        'Check to see if there's a command line
  11. WHILE F$=""
  12.     PRINT"This program will convert COM files to $INCLUDE files"
  13.     PRINT"for use with Turbo BASIC.  The default file type of"
  14.     PRINT"the source file is COM.  The default file type of the"
  15.     PRINT"output file is INC.  You may override either default"
  16.     PRINT"by entering a spacific file type specification."
  17.     PRINT"If you enter no name for the output file, it will be"
  18.     PRINT"named the same as the input file, but will have a file"
  19.     PRINT"type specification of INC."
  20.     LINE INPUT"Enter the name of the file to convert: ";F$
  21. WEND
  22.  
  23. IF COMMAND$="" THEN
  24.     LINE INPUT"Enter the name of the desired output file: ";O$
  25.     END IF
  26.  
  27. IF INSTR(F$,".")<2 THEN F$=F$+".COM"        'fix input spec
  28. IF O$="" THEN
  29.     O$=LEFT$(F$,INSTR(F$,"."))+"INC"        'fix output spec,
  30.     ELSE
  31.          IF INSTR(O$,".")<2 THEN O$=O$+".INC"    'both ways.
  32.     END IF
  33.  
  34. OPEN"R",1,F$,1          'input file will be read one byte
  35. FIELD #1,1 AS A$        'at a time into A$
  36. LASTBYTE=LOF(1)         'end of file position
  37. OPEN"O",2,O$            'output file is opened
  38. FOR I=1 TO LASTBYTE-1
  39.     GET 1,I
  40.     X=ASC(A$)
  41.     IF ((I-1) MOD 5=0) THEN PRINT #2,"":PRINT #2,"$INLINE ";
  42.     PRINT #2,"&H";HEX$(X);
  43.     IF ((I-1) MOD 5<>4) THEN PRINT #2,",";
  44. NEXT I
  45. GET 1,LASTBYTE
  46. PRINT #2,"&H";HEX$(ASC(A$))
  47. CLOSE
  48. PRINT"Conversion is complete. ";LASTBYTE;" bytes read."
  49. END
  50.  
  51.